  <%match = Match.find(sid)%>
  <%match_not_placed =  !(@user||current_user).bets.map{|b| b.match_id}.include?(sid.to_i)%>
 <!--place challenge-->
 <%if !match_not_placed%>
   <%if u%>
     <%=link_to "Challenge<br/>" + u.name,"#",:clicktoshowdialog=>"dialog_#{sid}_#{u.id}"%>
     <%=render :partial=>'friends_bet/place_challenge',:locals=>{:sid=>sid,:u=>u}%>
   <%else%>
     <%=link_to "Challenge your friends","#",:clicktoshowdialog=>"dialog_#{sid.to_s + (u.nil? ? "" : "_" + u.id.to_s)}" if Time.now < match.begin_at%></span>
     <%=render :partial=>'friends_bet/place_challenge',:locals=>{:sid=>sid,:u=>u}%>
   <%end%>
  <%else%>
    <%if u%>
       <%=link_to "Challenge<br/>" + u.name,"#",:onclick=>"showDialog('#{@call_back_url + "/friends_bet/gen_dialog?sid=" + sid.to_s + "&uid=" + u.id.to_s}');return false" if Time.now < match.begin_at%></span>
    <%else%>
       <%=link_to "Challenge your friends","#match_#{sid}",:onclick=>"showDialog('#{@call_back_url + "/friends_bet/gen_dialog?sid=" + sid.to_s}');return false" if Time.now < match.begin_at%></span>
     <%end%>
  <%end%>
